package top.xunfong.domain;

import cn.hutool.core.util.StrUtil;
import lombok.Builder;
import lombok.Data;

/**
 * 行信息
 *
 * @author: xunfong
 * @date: 2025/10/17 8:18
 */
@Builder
@Data
public class ColumnInfo {

    private String columnName;
    private String dataType;
    private String remarks;
    private String isNullable;
    private String columnDefault;

    // 获取Java属性名
    public String getPropertyName() {
        return StrUtil.toCamelCase(columnName);
    }

    // 获取Java类型
    public String getJavaType() {
        return switch (dataType.toUpperCase()) {
            case "VARCHAR", "CHAR", "TEXT" -> "String";
            case "INT", "TINYINT", "SMALLINT" -> "Integer";
            case "BIGINT" -> "Long";
            case "DECIMAL" -> "BigDecimal";
            case "DATETIME", "TIMESTAMP" -> "Date";
            case "BIT" -> "Boolean";
            default -> "Object";
        };
    }

}
